package com.itheima.d7_stream;

import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class StreamTest3 {
    public static void main(String[] args) {
        List<Double> scores =new ArrayList<>();
        Collections.addAll(scores, 89.5, 90.5, 92.5, 95.5);
        scores.stream().filter(s->s>=90).sorted().forEach(System.out::println);


        List<Student> students = new ArrayList<>();
        Student s1 = new Student("张三", 23,181);
        Student s2 = new Student("张二", 25,180);
        Student s3 = new Student("李四", 24,182);
        Collections.addAll(students, s1, s2, s3);

        students.stream().filter(s->s.getAge()>=24).sorted((o1, o2)->{
            return o1.getAge()-o2.getAge();
        }).forEach(System.out::println);
        System.out.println("----------------------");

        students.stream().sorted(((o1, o2) -> Double.compare(o1.getHeight(), o2.getHeight())))
                .limit(2).forEach(System.out::println);

        System.out.println("----------------------");

        students.stream().sorted(((o1, o2) -> Double.compare(o2.getHeight(), o1.getHeight())))
                .skip(students.size()-1).forEach(System.out::println);

        System.out.println("----------------------");

        students.stream().filter(s->s.getHeight() > 180).map(Student::getName)
                .distinct().forEach(System.out::println);

        students.stream().filter(s->s.getHeight() > 180)
                .distinct().forEach(System.out::println);

        System.out.println("----------------------");

        Stream<String> st1 =Stream.of("张三","李四");
        Stream<String> st2 =Stream.of("王五","赵六");
        Stream.concat(st1, st2).forEach(System.out::println);



}}
